package com.twu.biblioteca;


public class User {

    private String user_name, password;

    public User(String user_name, String password) throws Exception{
        this.user_name = user_name;
        this.password = password;

        if (!checkIfValid()){
            throw new Exception("Invalid values entered!");
        }
    }

    private boolean checkIfValid() {
        return !user_name.matches("") && !password.matches("") && user_name.matches("\\d{3}-\\d{4}");
    }

    public String login(String user_name, String password) {
        if (this.user_name.matches(user_name) && this.password.matches(password)){
            return "Successfully logged in!!";
        }
        else {
            return "Login unsuccessful!!";
        }
    }
}
